#include <iostream>
#include <string>
#include <set>
using namespace std;

int main(){
	set<string> heads;
	string str;
	cout << "Please input a polynomial:\n";
	cin >> str;
	const string symbolchars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	const string other="()*+-^ \t\n";
	for (size_t b=str.find_first_of(symbolchars,0); b!=string::npos;){
		 size_t e=str.find_first_not_of(symbolchars,b);	
		 if (e!=string::npos)
		 {
			heads.insert(string(str,b,e-b));
		  b=str.find_first_of(symbolchars,e);
		}
		else 
		{
			heads.insert(string(str,b,str.length()-b+1));
					break;
					}
	}
	cout << "The preprocessed symbols are :\n";
	for (set<string>::const_iterator i=heads.begin(); i!=heads.end(); i++)
			cout << *i << endl;
	return 0;
}		
